package Calculation;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-10-06
 * Time: 10:56
 */
public class Test4 {
    //盛水的容器
    class Solution2 {
        public int maxArea(int[] height) {
            int vMax = 0;
            int left = 0 , right = height.length-1;
            int v1 = Math.min(height[left] , height[right]) * (right -left);
            while(left != right){
                if(height[left] < height[right]){
                    left++;
                    int v2 = Math.min(height[left] , height[right]) * (right -left);
                    v1 = Math.max(v1 , v2);
                }else{
                    right--;
                    int v2 = Math.min(height[left] , height[right]) * (right -left);
                    v1 = Math.max(v1 , v2);
                }
                vMax = v1;
            }
            return vMax;
        }
    }
    class Solution1 {
        public int maxArea(int[] height) {
            int left = 0 ,right = height.length -1 , ret = 0;
            while(left < right){
                int v = Math.min(height[left],height[right]) * (right - left);
                ret = Math.max(ret,v);
                if(height[left] < height[right]){
                    left++;
                }else{
                    right--;
                }
            }
            return ret;

        }
    }

}
